Skip to content

Conversation

@federicobond
Copy link
Contributor

@federicobond federicobond commented Nov 21, 2025

Description

There was some weird double quoting going on in the settings panel values column. This fixes the formatting so it's more consistent and clearly distinguishes string from non-string values. Added some tests for the new behavior.

Before

Captura de pantalla 2025-11-21 a la(s) 9 07 48 p  m

After

Captura de pantalla 2025-11-21 a la(s) 8 43 21 p  m

Checklist:

  • I have added the relevant tests for this change.
  • I have added an item to the Pending section of docs/changes.rst.

@federicobond federicobond marked this pull request as ready for review November 21, 2025 09:44
Copy link
Member

@matthiask matthiask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Can you show an example of how it looks now?

{
"settings": {
key: force_str(value)
key: pformat(value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that force_str can just be removed? I think we added that to not crash when value contains binary data or something. Maybe pformat handles that just fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. It should return a string for most well-behaved objects but I can wrap it so it tolerates exceptions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has just been added here: https://github.com/django-commons/django-debug-toolbar/pull/2217/files

The bytes.fromhex value would probaly be a good test for this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pprint.pformat would format that bytes value as:

(b'\xa3\xf2\xb8\xc1N\x97-Z\x8f\xb3\xc7)\x1ad\xe0\x85\x9cG+\xf6=\x18\xa0\x94'
 b'^s\xb2\xc8O\x91z\xe2')

instead of "Django Debug Toolbar was unable to parse value."

``debug_toolbar.store.DatabaseStore`` with ``SKIP_TOOLBAR_QUERIES``.
* Fixed font family for code blocks and stack traces in the toolbar.
* Added test to confirm Django's ``TestCase.assertNumQueries`` works.
* Fixed display of values in settings panel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe more specific? Not sure if that's an improvement, just a suggestion.

Suggested change
* Fixed display of values in settings panel.
* Fixed double quoting of values in settings panel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work better?

Fixed string representation of values in settings panel

@github-actions
Copy link

github-actions bot commented Nov 21, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  debug_toolbar/panels
  profiling.py
  settings.py 14-15
Project Total  

This report was generated by python-coverage-comment-action

@federicobond
Copy link
Contributor Author

@matthiask the attached screenshot shows how it looks with this change. I added one with the current behavior just below.

@matthiask
Copy link
Member

@matthiask the attached screenshot shows how it looks with this change. I added one with the current behavior just below.

I'm sorry if I'm being dense but I only see one screenshot?

@federicobond
Copy link
Contributor Author

How about now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants